home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / OpenDoc Development / Debugging Support / OpenDoc Source Code / Imaging / PolygonClipper / PGPoly.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-22  |  3.3 KB  |  137 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        PGPoly.h
  3.  
  4.     Contains:    Polygon structs for the clipper.
  5.  
  6.     Owned by:    Jens Alfke (based on algorithm by A. C. Kilgour)
  7.  
  8.     Copyright:    © 1994 - 1995 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <4>     5/25/95    jpa        List.h --> LinkList.h [1253324]
  13.          <3>     9/29/94    RA        1189812: Mods for 68K build.
  14.          <2>      9/9/94    jpa        Changed _Log(ODPoint) to somPrintf(ODPoint)
  15.                                     due to redefinition of LOG macro.
  16.          <1>     6/15/94    jpa        first checked in
  17.          ---------------------------Moved to ODSOM project.
  18.          <1>      5/9/94    jpa        first checked in
  19.  
  20.     In Progress:
  21. */
  22.  
  23. #ifndef _PGPOLY_
  24. #define _PGPOLY_
  25.  
  26. #ifndef _ALTPOINT_
  27. #include "AltPoint.h"
  28. #endif
  29.  
  30. #ifndef _ODTYPES_
  31. #include "ODTypes.h"
  32. #endif
  33.  
  34. #ifndef _PGCOMMON_
  35. #include "PGCommon.h"
  36. #endif
  37.  
  38. #ifndef _LINKLIST_
  39. #include "LinkList.h"
  40. #endif
  41.  
  42.  
  43. struct ODPolygon;
  44. struct ODContour;
  45. struct PGEvent;
  46. struct PGEventQueue;
  47. struct PGEdge;
  48.  
  49. class PGContourList;
  50.  
  51.  
  52. PGSense Compare( const ODPoint*, const ODPoint* );
  53.  
  54.  
  55. void somPrintf( const ODPoint& );            // Overload of somPrintf, used only when logging
  56.  
  57.  
  58. // A PGVertex is a point stored in a linked list (but not a LinkedList) owned by a PGContour.
  59.  
  60. struct PGVertex :public ODPoint
  61. {
  62.     public:
  63.         PGVertex( const ODPoint*, PGVertex *prev );
  64.         
  65.         PGVertex*    GetPrevious( )    const    {return fPrevious;}
  66.         PGVertex*    GetNext( )    const        {return fNext;}
  67.         
  68.         void        Reverse( );
  69.         void        JamNext( PGVertex* );
  70.         
  71.         inline ODPoint& AsPoint( )                {return *(ODPoint*)this;}
  72.         inline const ODPoint& AsPoint( ) const    {return *(const ODPoint*)this;}
  73.     
  74. //    private:
  75.         PGVertex*    fPrevious;
  76.         PGVertex*    fNext;
  77. };
  78.  
  79.  
  80. // A PGContour is a contour of a polygon. It's a linked list of ODVertexes, but it's
  81. // not a descendent of LinkedList since it doesn't use a 'sentinel'. The vertices
  82. // form a pure circular list with no interruptions.
  83. // PGContours are themselves strung together into lists, so they inherit from Link.
  84.  
  85. struct PGContour :public Link
  86. {
  87.     public:
  88.         PGContour( LinkedList *onList );
  89.         virtual ~PGContour( );
  90.         
  91.         PGContour*    InitContour( const ODContour*, Boolean reverse );
  92.         void        AddAllEvents( PGEventQueue& );
  93.         
  94.         PGVertex*    First( )            {return fFirst;}
  95.         PGVertex*    Last( )                {return fLast;}
  96.         ODSLong    CountVertices( )    {return fNVertices;}
  97.         
  98.     protected:
  99.         PGVertex*    fFirst;                // First vertex in list
  100.         PGVertex*    fLast;                // Last vertex (not linked to 1st in PGOutputContours!)
  101.         ODSLong    fNVertices;            // Number of vertices in list
  102. };
  103.  
  104.  
  105. struct PGOutputContour :public PGContour
  106. {
  107.     public:
  108.         PGOutputContour( const PGEdge *left, const PGEdge *right );
  109.         
  110.         void        AddVertex( PGSide, const ODPoint* );
  111.         void        Close( );
  112.         void        AppendContour( PGOutputContour *cont, PGSide toSide );
  113.         
  114.         ODSShort    fWrapNo;            // Wrap number of this contour
  115.         PGSense        fSense;                // kPositive means clockwise
  116.     
  117.     // The following are not used by the clipper, but by Rgn2PlyM.cpp.
  118.     // Both take QuickDraw coordinates:
  119.         PGOutputContour( short x, short y );
  120.         void        AddVertex( PGSide, short x, short y );
  121. };
  122.  
  123.  
  124. // kIgnoredOutput is a special output-contour-pointer used to indicate that
  125. // there is an output contour but it is not needed (due to its wrap number.)
  126. #define kIgnoredOutput ((PGOutputContour*)0xFFFFFFFF)
  127.  
  128.  
  129. class PGContourList :public LinkedList
  130. {
  131.     public:
  132.         void        ReadPolygon( const ODPolygon&, Boolean reverse, PGEventQueue& );
  133.         void        BuildPolygon( ODPolygon& );
  134. };
  135.  
  136.  
  137. #endif /*_PGPOLY*/